#!/bin/bash

set -e
set -x

# yum install -y bzip2-devel ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel openssl-devel readline-devel libnsl2-devel --downloadonly --downloaddir=Python-3.10.16-rpm-devel
bypy download Python-3.10.16-rpm-devel.tgz
bypy download Python-3.10.16.tgz

tar xf Python-3.10.16-rpm-devel.tgz
yum -y --disablerepo='*' localinstall Python-3.10.16-rpm-devel/*.rpm

tar xf Python-3.10.16.tgz
cd Python-3.10.16
./configure --prefix=/usr/local/python3.10
make
make install

cat > /etc/profile.d/python_env.sh <<'EOF'
export PATH=/usr/local/python3.10/bin:$PATH
EOF

ln -fs /usr/local/python3.10/bin/python3.10 /usr/local/bin/python
ln -fs /usr/local/python3.10/bin/pip3 /usr/local/bin/pip
ln -fs /usr/local/python3.10/bin/python3.10 /usr/local/bin/python3
ln -fs /usr/local/python3.10/bin/pip3 /usr/local/bin/pip3


set +x
set +e